//index.js
var util= require("../../utils/libs.js");
var api = require("../../utils/api.js");
var util= require("../../utils/libs.js")
//获取应用实例
const app = getApp()

Page({
  data: {
    uid:1,
    show:true,
    id:null,
    article:"",
    page:0,
    detail:{}
  },
  topicDraft(){
    let that = this
    util.request(api.topicDetail,{id:that.data.id},"GET")
    .then(function (res) {
      if(res.error_code === 0){
        let arr = res.data.topic
        that.setData({
          detail:arr
         })
      }
    })
  },
  articleList(){
    let that = this
    util.request(api.topicArticleDetail,{uid:that.data.uid,
      id:that.data.id
    },"GET")
    .then(function (res) {
      if(res.error_code === 0){
        that.setData({
          article:res.data.article
        })
      }
    })
  },
  showAll(){
    let that = this
    wx.navigateTo({
      url:"/pages/writing/writing?id="+that.data.id
    })
  },
  toFabu(){
     wx.navigateTo({
       url:"/pages/addwrting/addwrting"
     })
  },
  onLoad(options){
   let that = this
   let uid = wx.getStorageSync("uid")
   that.setData({
     id:options.id,
     uid:uid
   })
   that.topicDraft()
   that.articleList()
  }
})
